﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using CMN.Models;
using CMN.Models.Interfaces;
using CMN.Entity;
using CMN.Controllers;
using CMN.Controllers.Filters;
using CMN.Common;
using System.Text;
using CMN.UI;
using CMN.Framework;
using CMN.Config;
namespace CMN.Controllers
{
    [UserAuthorize]
    [LoggerFilter()]
    [ExceptionFilter()]
    [ExecutionTimingAttribute()]
    public class AllShowController : Controller
    {
        [CompressFilter]
        [CacheFilterAttribute]
        public string Index(int pageIndex)
        {
            PageHelperEntity pageHelper = new PageHelperEntity();
            pageHelper.Title = "全部内容";
            pageHelper.PageIndex = pageIndex;
            pageHelper.ChannelId = 0;
            pageHelper.Type = PageType.OtherPage;
            string strRetrun = string.Empty;
            if (pageIndex > 1)
            {
                pageHelper.OtherTypeName = "allShow";
                BaseTemplateDisplay articleTemplate = new BaseTemplateDisplay(pageHelper);
                strRetrun = articleTemplate.Display();
                articleTemplate.Dispose();
            }
            else
            {
                pageHelper.OtherTypeName = "indexShow";
                string htmlPath = string.Concat(Utils.GetServerPath(), "App_Data\\html\\indexShow.htm");

                SiteConfigInfo siteInfo = SiteConfigs.GetSiteConfig();
                if (Utils.FileIsOld(htmlPath, siteInfo.CacheSecond))
                {
                    strRetrun = Utils.GetFileContent(htmlPath, Encoding.GetEncoding("gb2312"));
                }
                else
                {
                    BaseTemplateDisplay articleTemplate = new BaseTemplateDisplay(pageHelper);
                    strRetrun = articleTemplate.Display();
                    articleTemplate.Dispose();
                    Utils.CreateFile(htmlPath, strRetrun, null);
                }
            }
           
            
            return strRetrun;
        }



        
    }
}
